* This file produces a whisker plot of the coefficients of the main model

cd O:\2.21-oilwork\data
use "oilwork-for-clarify", clear

* Simple effect of energy employment using Clarify
gen blagovostok=.
gen kxaixllw=.
drop b*
drop kx*

gen kxm=.
gen kxu=.
gen kxl=.
gen kxx=.
gen kxse=.
replace kxx=_n

**********************************
* Policies and measures (IPCC WG3) 
*******************************************************************
* THREATS
*  Reduce tax incentives/Tighten tax regulation regarding oilfield exploration
* estsimp regress oiltax0 oilwork2 age gender edu3 incomeLOG /* expoiltaxincent */
estsimp regress oiltax0 oilwork2 age gender edu3 incomeLOG expoiltaxincent 
estsimp regress oiltax0 oilwork2 ageI* gender eduI* incomeLOG regionI* expoiltaxincent [pw=w01_Weight2]
setx mean
setx oilwork2 1
simqi, genev(pi)
su pi, detail
local order=3
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi

setx mean
setx oilwork2 0
simqi, genev(pi)
su pi, detail
local order=`order'+1
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi
drop b*


* Support policy not to consider Lofoten, Vesteraalen, Senja oil next 4 years
estsimp regress lofnooilR3 oilwork2 age gender edu3 incomeLOG 
* could also try lofnooilR2?
setx mean
setx oilwork2 1
simqi, genev(pi)
su pi, detail
local order=6
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi

setx mean
setx oilwork2 0
simqi, genev(pi)
su pi, detail
local order=`order'+1
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi
drop b*

* Reduce (or increase) Norwegian oil production
estsimp regress redincoil0 oilwork2 age gender edu3 incomeLOG 
setx mean
setx oilwork2 1
simqi, genev(pi)
su pi, detail
local order=9
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi

setx mean
setx oilwork2 0
simqi, genev(pi)
su pi, detail
local order=`order'+1
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi
drop b*




* Threat #4: Tighten emissions ceiling / ETS 2013
estsimp regress tighten0 oilwork2 age gender edu3 incomeLOG     
* estsimp regress tighten0 oilwork2 age gender edu3 incomeLOG     etsmentiondummy
setx mean
setx oilwork2 1
simqi, genev(pi)
su pi, detail
local order=12
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi

setx mean
setx oilwork2 0
simqi, genev(pi)
su pi, detail
local order=`order'+1
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi
drop b*




* OPPORTUNITIES
* CCS 2013 (because it has the largest n: 1396) omit CCS 2014 (n=500) 
estsimp regress ccs0 oilwork2 age gender edu3 incomeLOG
estsimp regress oiltax0 oilwork2 ageI* gender eduI* incomeLOG regionI* expoiltaxincent [pw=w01_Weight2]
setx mean
setx oilwork2 1
simqi, genev(pi)
su pi, detail
local order=15
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi

setx mean
setx oilwork2 0
simqi, genev(pi)
su pi, detail
local order=`order'+1
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi
drop b*


* Renewables govt support: Offshore wind (round 3) 
estsimp regress ofshwind oilwork2 age gender edu3 incomeLOG 
setx mean
setx oilwork2 1
simqi, genev(pi)
su pi, detail
local order=18
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi

setx mean
setx oilwork2 0
simqi, genev(pi)
su pi, detail
local order=`order'+1
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi
drop b*


* Renewables govt support: Geotherm (round 3) 
estsimp regress geotherm oilwork2 age gender edu3 incomeLOG 
setx mean
setx oilwork2 1
simqi, genev(pi)
su pi, detail
local order=21
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi

setx mean
setx oilwork2 0
simqi, genev(pi)
su pi, detail
local order=`order'+1
replace kxm=r(mean) in `order'
replace kxu=r(p95) in `order'
replace kxl=r(p5) in `order'
replace kxse=r(sd) in `order'
drop pi
drop b*

*** GRAPH IT ***
label define kxlabels ///
   3 "Tighten tax" 4 "Tighten tax: oil work" ///
   5 " " ///
   6 "Postpone Lofoten" 7 "Postpone Lofoten: oil work" ///
   8 " " ///
   9 "Reduce oil prod"  10 "Reduce oil prod: oil work" ///
   11 " " ///
   12 "Tighten emissions" 13 "Tighten emissions: oil work" ///
   14 " " ///
   15 "Carbon capture" 16 "CCS: oil work" ///
   17 " " ///
   18 "Offshore wind" 19 "Offshore wind: oil work" ///
   20 " " ///
   21 "Geothermal" 22 "Geothermal: oil work" ///
   , replace
 
label values kxx kxlabels


  /*
twoway (rcap kxu kxl kxx) ///
       (scatter kxm kxx, msymbol (o)) in 3/22 ///
	   ,  xlabel(3 (3) 21,valuelabel angle(vertical))  ///
	   ytitle("Policy support", height(8)) xtitle("")  ///
   graphregion(color(white)) bgcolor(white) xline(5 8 11 14 17 20, lstyle(grid)) ///
   legend(off)
    */ 

* development: 	 
twoway (scatter kxm kxx if mod(kxx,3)==1, msymbol (o))  ///
       (scatter kxm kxx if mod(kxx,3)==0, msymbol (Th))  ///
	   (rcap kxu kxl kxx) in 3/22 /// Error bars 
	   ,  xlabel(3 (3) 21,valuelabel angle(vertical))  ///
	   ytitle("Policy support", height(8)) xtitle("")  ///
   graphregion(color(white)) bgcolor(white) xline(5 8 11 14 17 20, lstyle(grid)) ///
   legend(order(2 "Oil work" 1 "Not oil work" ) bplacement(center))
      
	  
	  
	  
	  
	  
	  
	  
   
* -serrbar- is a historical hangover. It is not, I guess, general enough to do  what you want, and I don't think the  documentation claims otherwise. 
* What you want is just a composite -twoway-, I imagine.    
 /*  
serrbar kxm kxse kxx if kxx<=22 & kxx>2, scale(2) xlabel(3 (3) 21,valuelabel angle(vertical)) ///
   msymbol(Oh S i) ///
   ytitle("Policy support", height(8)) xtitle("")  ///
   graphregion(color(white)) bgcolor(white) xline(5 8 11 14 17 20, lstyle(grid))
*/  
   
   
   
   
   
